package com.shanghaionstar.weight;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;

import com.shanghaionstar.R;

/**
 * Created by Yonglang Hong on 2016/12/12.
 */
public class AddMoreView extends LinearLayout {

    private View progressBar, textView;

    public AddMoreView(Context context) {
        super(context);
        init();
    }

    private void init() {
        setOrientation(HORIZONTAL);
        setGravity(Gravity.CENTER);
        int padding = getResources().getDimensionPixelSize(R.dimen.dp_5);
        setPadding(padding,padding,padding,padding+padding);
        inflate(getContext(), R.layout.add_more_layout, this);
        progressBar = findViewById(R.id.pbar_addMore);
        textView = findViewById(R.id.tv_addMore);
    }

    public void showLoading() {
        progressBar.setVisibility(View.VISIBLE);
        textView.setVisibility(View.GONE);
    }

    public boolean isLoading(){
        return progressBar.getVisibility() == View.VISIBLE;
    }

    public void showNormal() {
        progressBar.setVisibility(View.GONE);
        textView.setVisibility(View.VISIBLE);
    }
}
